﻿namespace worker_service.Tools
{
    /// <summary>
    /// HttpClient 单例类
    /// </summary>
    public class HttpClientSingleton
    {
        private static readonly HttpClientSingleton instance = new();

        private readonly HttpClient httpClient;

        private HttpClientSingleton()
        {
            httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(5) };
        }

        //public static HttpClientSingleton Instance => instance; // 如果类有其他函数需要提供时使用

        public static HttpClient HttpClient => instance.httpClient; // 只为复用 HttpClient 实例
    }
}
